﻿using System.Data.Objects;

namespace Repositories.Implementations
{
  /// <summary>
  /// Object Context Manager class which applying Singleton pattern
  /// </summary>
  public static class ObjectContextManager
  {
    private static ObjectContext _currentContext;

    /// <summary>
    /// Used to get the current object context session
    /// </summary>
    public static ObjectContext Current
    {
      get
      {
        return _currentContext;
      }
    }

    /// <summary>
    /// Inits the specified context.
    /// </summary>
    /// <param name="context">The context.</param>
    public static void Init( ObjectContext context )
    {
      if( _currentContext == null )
      {
        _currentContext = context;
      }
    }

    public static void Dispose()
    {
      _currentContext = null;
    }
  }
}
